<?php
error_reporting(0);
header("Content-type: text/html; charset=utf-8"); 
$isadmin=1; 
include_once '../comm/config.php';
include_once '../comm/checkpostandget.php';
include_once "check.php";

function get_field_info($dbname, $table,$field, $info) {
	$sql_fields = mysql_list_fields($dbname, $table);
	$columns = mysql_num_fields($sql_fields);
	$sq_table = "select * from ".$table;
    $query_table = mysql_query($sq_table) or die("查询数据失败"); //执行查询
	$funname = 'mysql_field_' . $info;
	for ($i = 0; $i < $columns; $i++) {
		$field_pro = $funname ($query_table, $i);
		$field_name = trim(mysql_field_name($sql_fields, $i));
		if($field_name==$field){
			return $field_pro;
		}
	}
	mysql_free_result($query_table);
}

$startlevel=$_POST['startlevel'];
$endlevel=$_POST['endlevel'];
	
$sql = "delete from ".$BIAOTOU."shop where level>='".$startlevel."' and level<='".$endlevel."'";
mysql_query($sql);

$sql = "delete from ".$BIAOTOU."shop where good='' or good is null or fanxianlv is null or fanxianlv =''";
mysql_query($sql);

if(get_field_info($dbname, $BIAOTOU.'shop','fanxianlv', 'flags')==''){
    $sql="ALTER TABLE `".$BIAOTOU."shop` ADD INDEX ( `fanxianlv` ) ";
	mysql_query($sql);
}

if(get_field_info($dbname, $BIAOTOU.'shop','good', 'flags')==''){
    $sql="ALTER TABLE `".$BIAOTOU."shop` ADD INDEX ( `good` ) ";
	mysql_query($sql);
}
admin_log('删除淘宝店铺');
mysql_close();
?>
<script language=javascript>
alert('删除成功！');
window.history.go(-1);
</script>